from django.db import models

# Create your models here.
# 听书资源


class AudioBook(models.Model):
    # 书ID
    bookId = models.CharField(unique=True, max_length=40)
    # 书名
    bookName = models.CharField(max_length=20)
    # 封面
    img = models.CharField(max_length=255)
    # 是否付费
    pay = models.CharField(max_length=20)
    # 价格(券/币)
    price = models.DecimalField(null=True, decimal_places=0, max_digits=20)
    # 类型
    type = models.CharField(max_length=50)
    # 书介绍
    bookInfo = models.CharField(max_length=255)
    # 播放次数
    playCount = models.DecimalField(decimal_places=0, max_digits=30)
    # 主播
    anchor = models.CharField(max_length=20)
    # 上架时间
    date = models.DateField()

# chapter听书章节列表


class Chapter(models.Model):
    # 章节id
    chapterId = models.CharField(max_length=50)
    # 章节名称
    chapterName = models.CharField(max_length=50, null=True)
    # 所属书籍ID
    bookId = models.ForeignKey(
        'AudioBook', to_field='bookId', on_delete=models.CASCADE)


class Swiper(models.Model):
    # 对应书ID
    bookId = models.ForeignKey(
        'AudioBook', to_field='bookId', on_delete=models.CASCADE)
    # 轮播图片
    image = models.CharField(max_length=255)
    # 分类
    types = models.CharField(max_length=20)
